$(function () {

        $('#regForm').validate({
        	//检测用户名
            username_reg: {
                rule: {
                    required: true,
                   	regexp: /^\w{6,12}$/,
                   	ajax:{url:checkUser}
                },
                error: {
                    required: '用户名不能为空',
                    regexp:'用户名至少要6位到12位a-zA-Z',
                    ajax:{url:checkUser}
                },
                success: '验证通过',
                message: '请输入用户名'
            },
            //检测昵称
            nickname: {
                rule: {
                    required: true,
                   	minlen:1,
                   	maxlen:10,
                   	ajax:{url:checkNick}
                },
                error: {
                    required: '昵称不能为空',
                    minlen:'昵称不得少于1个字符',
                    maxlen:'昵称不能大于10个字符',
                    ajax:{url:checkNick}
                },
                success: '验证通过',
                message: '请输入昵称'
            },
             password_reg1: {
	                rule: {
	                    required: true,
	                    minlen:6,
	                 	maxlen:12,
	                    confirm: 'password_reg2'
	                },
	                error: {
	                    required: '密码不能为空',
	                    minlen:'密码不得少于6位字符',
	                    maxlen:'密码不得超过12位字符',
	                    confirm: '两次密码不一致'
	                },
	                success:'ok',
					message:'请填写密码'
	            },
	          password_reg2 : {
				rule:{
					required:true,
					minlen:6,
	                maxlen:12,
					confirm:'password_reg1'
				},
				error:{
					 required: '密码不能为空',
	                 minlen:'密码不得少于6位字符',
	                 maxlen:'密码不得超过12位字符',
	                 confirm: '两次密码不一致'
				},
				success:'ok',
				message:'请填写密码'
			},
			code:{
				rule:{
					required:true,
					ajax:{url:checkCode}
				},
				error:{
					required:'验证码必须填写',
					ajax:{url:checkCode}
				},
				message:'请填写验证码'
			}
           
        })
         $('#loginForm').validate({
        	//检测用户名
            username: {
                rule: {
                    required: true,
                   	regexp: /^\w{6,12}$/,
                },
                error: {
                    required: '用户名不能为空',
                    regexp:'用户名至少要6位到12位a-zA-Z',
                },
                success: 'ok',
                message: '请输入用户名'
            },
            password: {
	                rule: {
	                    required: true,
	                    minlen:6,
	                 	maxlen:12,
	                },
	                error: {
	                    required: '密码不能为空',
	                    minlen:'密码不得少于6位字符',
	                    maxlen:'密码不得超过12位字符'
	                },
	                success:'ok',
					message:'请填写密码'
	            },
        })
    })